Blog.

How to remove all children of a tree node

Code in this post can be obsolete, however, principles and theory may still apply.
Suppose we want to remove all children of the node node:

while(node.firstChild) {
    node.removeChild(node.firstChild);
}

That’s all there is to it

saki
Follow me:
Latest posts by saki (see all)

14 Responses

  1. Hi, I am trying to remove the nodes like in your example and than add them again. Firstly I have a memory leak after that, and also sometimes i have an awfull “this.target is null
    error source line: [Break on this error] Ext.ToolTip=Ext.extend(Ext.Tip,{showDe…ithin(this.target.dom,true)){return;}” error );

  2. Just to bring to ppls attention, there’s a new removeAll method on the tree node. Looks like its only in version 3.2 and not 3.1 (worked that out the hard way). removeChild also doesn’t work in 3.1 but fixed in 3.2.

  3. are you the maker of the extjs wordpress template?

    i like it and i see the features of 2.0?
    is this still under development??

    greets

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Enter your username and password to log into your account. Don't have an account? Sign up.

Want to collaborate on an upcoming project?